package cn.javabb.phonebook.service;

import cn.javabb.phonebook.entity.PhoneBook;
import cn.javabb.phonebook.mapper.PhoneBookMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @desc:
 * @author: javabb (javabob(a)163.com)
 * @create: 2020/05/03 15:46
 */
@Service
public class PhoneBookService {

    @Autowired
    private PhoneBookMapper phoneBookMapper;

    public List<PhoneBook> loadByInitial(String initial) {
        return phoneBookMapper.loadByInitial(initial);
    }

    public Integer add(PhoneBook phoneBook) {
        return phoneBookMapper.insert(phoneBook);
    }

    public Integer update(PhoneBook phoneBook) {
        return phoneBookMapper.updateByPrimaryKeySelective(phoneBook);
    }

    public PhoneBook findById(Integer id) {
        return phoneBookMapper.selectByPrimaryKey(id);
    }

    public Integer delete(Integer id) {
        return phoneBookMapper.deleteByPrimaryKey(id);
    }
}
